#ifndef __WXCONTROL2D__
#define __WXCONTROL2D__

#include "..\Control2DBase.h"
#include "..\..\Rendering\OGL\GLRenderer.h"

class wxGLCanvas;
class wxGLContext;
class wxSizeEvent;
class wxMouseEvent;
class wxPaintEvent;

class wxGLRenderer : public GLRenderer
{
public:
	wxGLRenderer()
	{
	}

	void CreateContext(void *control, void *context);
	void MakeCurrent(void *control, void *context);
	void SwapBuffers(void *control);
};

class wxControl2D : public Control2DBase
{
	GLRenderer *_glRenderer;

public:
	/// <summary>
	/// Get the control that we are rendering to.
	/// </summary>
	wxGLCanvas *Control;

	/// <summary>
	/// The context
	/// </summary>
	wxGLContext *Context;

	/// <summary>
	/// Constructor.
	/// </summary>
	/// <param name="control">Control to render to</param>
	/// <param name="renderer">The renderer for the control</param>
	/// <param name="viewport">The viewport we are rendering</param>
	wxControl2D(wxGLCanvas *control, wxGLContext *context, wxGLRenderer *renderer, const Viewport &viewport);
	~wxControl2D();

	/// <summary>
	/// Get the handle for the control.
	/// </summary>
	void *GetHandle() const;

	void ResetValues();
	
	void control_SizeChanged(wxSizeEvent &e);
	void control_MouseWheel(wxMouseEvent &e);
	void control_MouseUp(wxMouseEvent &e);
	void control_MouseMove(wxMouseEvent &e);
	void control_MouseDown(wxMouseEvent &e);
	void control_Paint(wxPaintEvent &e);

	/// <summary>
	/// Refresh the control.
	/// </summary>
	void Refresh();

	/// <summary>
	/// Get the width of the GDI control.
	/// </summary>
	int GetWidth() const;

	/// <summary>
	/// Get the height of the GDI control.
	/// </summary>
	int GetHeight() const;
};

#endif